﻿<!DOCTYPE html>
<html><head><meta charset="UTF-8">
<title></title>

<script>
	onload = function(){
		var box = document.getElementById("box");
		box.onmousedown = function(e){
			var e = e || event;
			var disX = e.offsetX;
			var disY = e.offsetY;
			document.onmousemove = function(e){
				var e = e || event;
				box.style.left = e.clientX - disX + "px";
				box.style.top = e.clientY - disY + "px";
			}
		}
		document.onmouseup = function(){
			document.onmousemove = "";
		}
	}
</script>
</head>
<body>
	<div id="box" style="position:absolute; left:0; top:0; width:200px;height:200px;background:red"></div>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
	<p>aaa</p>
</body>
</html>